package com.egreen.user.controller;


import com.egreen.common.Result;
import com.egreen.common.States;
import com.egreen.common.pojo.DTO.user.userLocationDTO.UserLocationUpdateDTO;
import com.egreen.user.service.IUserLocationService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cloudJiang
 * @since 2022-07-16
 */
@RestController
@RequestMapping("/userLocation")
public class UserLocationController {
    @Autowired
    IUserLocationService userLocationService;

    @ApiOperation(value = "用户地址更新",notes ="通过调用userLocationUpdate方法，完成对用户地址的更新")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "用户ID",required = true),
            @ApiImplicitParam(name = "country",value = "位置所在国家",required = true),
            @ApiImplicitParam(name = "province",value = "位置所在省份",required = true),
            @ApiImplicitParam(name = "cityName",value = "位置所在城市名",required = true),
            @ApiImplicitParam(name = "district",value = "位置所在区域",required = true),
            @ApiImplicitParam(name = "community",value = "位置所在社区",required = true),
            @ApiImplicitParam(name = "locationDetails",value = "详细地址（详细到门牌号）",required = true),
            @ApiImplicitParam(name = "applicationForAgencyDTO",value = "以上七个参数封装在此DTO中")
    })
    @PostMapping("/userLocationUpdate")
    Result userLocationUpdate(@Validated @RequestBody UserLocationUpdateDTO userLocationUpdateDTO) {
        userLocationService.userLocationUpdate(userLocationUpdateDTO);
        return Result.OK(States.OK);
    }
}

